package com.lc.demo.result;

public class ResponseMessage {


    private final static String STATUS_OK = "200";
    private final static String STATUS_ERROR = "500";

    private String status;     // 状态
    private Object data;   // 返回值
    private String msg;    // 自定义信息

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public ResponseMessage() {
        super();
    }




    public ResponseMessage(String status, Object data, String msg) {
        super();
        this.status = status;
        this.data = data;
        this.msg = msg;
    }

    public ResponseMessage(String status, String msg) {
        super();
        this.status = status;
        this.msg = msg;
    }
    /**
     * 成功的结果
     *
     */
    public static ResponseMessage success() {
        return new ResponseMessage(ResponseMessage.STATUS_OK, "接口请求成功");
    }

    /**
     * 成功的结果
     *
     * @param msg  返回信息
     */
    public static ResponseMessage successWithMessage( String msg) {
        return new ResponseMessage(ResponseMessage.STATUS_OK, msg);
    }

    /**
     * 成功的结果
     *
     */
    public static ResponseMessage successWithData( Object data) {
        return new ResponseMessage(ResponseMessage.STATUS_OK, data,"接口请求成功");
    }

    /**
     * 成功的结果
     *
     * @param data 返回结果
     * @param msg  返回信息
     */
    public static ResponseMessage successWithMessageData(Object data, String msg) {
        return new ResponseMessage(ResponseMessage.STATUS_OK, data, msg);
    }




    /**
     * 失败的结果
     *
     */
    public static ResponseMessage error() {
        return new ResponseMessage(ResponseMessage.STATUS_ERROR,  "接口请求错误");
    }

    /**
     * 失败的结果
     *
     * @param msg 返回信息
     */
    public static ResponseMessage errorWithMessage(String msg) {
        return new ResponseMessage(ResponseMessage.STATUS_ERROR, null, msg);
    }



    /**
     * 失败的结果
     *
     * @param msg 返回信息
     */
    public static ResponseMessage errorWithMessageData(String msg ,Object data) {
        return new ResponseMessage(ResponseMessage.STATUS_ERROR, data,  msg);
    }
}
